package cn.hl.sfzy.controller;

import cn.hl.sfzy.entity.Article;
import cn.hl.sfzy.entity.Articletype;
import cn.hl.sfzy.entity.Heartknowledge;
import cn.hl.sfzy.entity.Heartmark;
import cn.hl.sfzy.service.ArticletypeService;
import cn.hl.sfzy.service.HeartknowledgeService;
import cn.hl.sfzy.util.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

@RestController
@RequestMapping("/articletype")
public class ArticletypeController {
    @Autowired
    private ArticletypeService articletypeService;
    @GetMapping("/find")
    public Result find(
            @RequestParam(required = false,defaultValue = "1") int pageNum,
            @RequestParam(required = false,defaultValue = "5") int pageSize,
            Articletype articletype
    ){
        PageInfo<Articletype> bypage =articletypeService.findBypage(pageNum, pageSize,articletype);
        Result result=Result.success(bypage);
        return result;
    }
    @PostMapping("/add")
    public Result add(@RequestBody Articletype articletype){
        System.out.println(articletype.toString());
        System.out.println(articletype);
        int i = articletypeService.add(articletype);
        return Result.success(articletype);
    }
    @PutMapping("/update")
    public Result update(@RequestBody Articletype articletype){
        int update = articletypeService.update(articletype);
        return Result.success(articletype);
    }
    @PutMapping("/updateid/{id}")
    public Result updateid(@PathVariable Long id  ,  @RequestBody Long[] o ){
        int update = articletypeService.updateid(id,o);



        return Result.success("aass");
    }
    @DeleteMapping("/delete/{id}")
    public Result deleteById(@PathVariable Long id){
        System.out.println(id);
        articletypeService.deleteById(id);
        return Result.success("删除成功");
    }
}
